﻿<UserControl x:Name="userControl" 
             x:Class="DotBeer.UI.WPFClient.AutoCompleteControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:UI="clr-namespace:DotBeer.UI.WPFClient">
    <Popup x:Name="popup" AllowsTransparency="True" >
        <ListBox x:Name="listBox"
                 Style="{StaticResource ListBoxStyle}"
                 MaxHeight="100"
                 Width="{Binding TargetControl.Width, ElementName=userControl}"
                 ItemsSource="{Binding Items, ElementName=userControl, Mode=Default}"
                 ScrollViewer.HorizontalScrollBarVisibility="Hidden"
                 SelectedItem="{Binding TargetControl.Text, ElementName=userControl}">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <Image Width="20" Height="20" Source="{Binding ImagePath}" Margin="2,2,2,2"/>
                        <TextBlock Text="{Binding Name}" Margin="2,2,2,2" VerticalAlignment="Center"/>
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </Popup>
</UserControl>
